#include <iostream>
using namespace std;
#include "client.h"
#include "log_reader.h"
#include "console_sender.h"
#include "socket_sender.h"
#include "data.h"

Client::Client(LogReader & log_reader,LogSender & log_sender):log_reader(log_reader),log_sender(log_sender){}

//采集数据
void Client::dataMine() throw (ClientException)
{	
	cout << "DMS客户端开始采集数据..." << endl << endl;
	sleep(1);
	
	list<MatchedLogRec> & matched_log = log_reader.readLog(); //通过readLog()读取到匹配成功的日志记录，这一步非常关键！没有了它就没有了后续的其它工作！
	
	ConsoleSender console_sender;       //创建一个继承了Sender类的ConsoleSender类的对象，以满足Sender类中虚函数的调用规则
	console_sender.sendLog(matched_log);//将匹配好的登入登出日志记录输出到终端
	
	SocketSender socket_sender;
	socket_sender.sendLog(matched_log); //将匹配好的登入登出日志记录发送到服务端
	
	cout << "DMS客户端已完成数据采集与匹配！并将数据发送至服务端！" << endl;
	sleep(1);
}

